package com.casicloud.manage.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.casicloud.manage.mapper.AuthorityMapper;
import com.casicloud.manage.mapper.RoleMapper;
import com.casicloud.manage.model.Role;
import com.casicloud.manage.service.RoleService;
import com.common.sub.util.PageUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@Service
public class RoleServiceImpl implements RoleService{
	
	@Autowired
	private AuthorityMapper authorityMapper;
	
	@Autowired
	private RoleMapper roleMapper;

	@Override
	public List<Role> findByList(Role role) {
		return roleMapper.findByList(role);
	}

	@Override
	public Role findByOne(Role role) {
		return roleMapper.findByOne(role);
	}

	@Override
	public void save(Role role) {
		role.setCreateTime(new Date());
		roleMapper.save(role);
		
	}

	@Override
	public void save(Role role, Integer... authorityIds) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public int update(Role role) {
		role.setCreateTime(new Date());
		return roleMapper.update(role);
	}

	@Override
	public int delete(Role role) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public PageInfo<Role> findByPage(PageUtil pageUtil, Role role) {
		Page<Role> p = PageHelper.startPage(pageUtil.getPage(), pageUtil.getRows());
		roleMapper.findByList(role);
		return new PageInfo<Role>(p);
	}

}
